import React,{Component} from 'react';
import {
	Text,
	View,
	Animated,
	LayoutAnimation,
	BackAndroid,
	TouchableWithoutFeedback,
	Easing,
	Dimensions,
	Image,
	StyleSheet,
	BackHandler,
	Alert
} from 'react-native';

class CustomImage extends Component{
	constructor(props) {
	  super(props);
	
	  this.state = {
		h:0,
		w:Dimensions.get('window').width
	  };
	}
	componentDidMount(){
		var url = this.props.url;
		// console.log(Image.getSize,url);
		// console.log(this.props);
		// Alert.alert(url);
		// console.log()
		// console.log(source.() );
		Image.getSize(url,(width,height)=>{
			console.log(width,height,'getSize');
			var scale=width/height;
			var h=this.state.w/scale;
			this.setState({
				h:h
			});
		})
	}
	render(){
		var {source,style,...props} = this.props;

		return (
				<Image 
					{...props}
					style={[style,{width:this.state.w,height:this.state.h}]}
					source={source}
				/>
			);
	}
}
export default CustomImage